<?php

namespace App\Http\Controllers\Strator;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;

class StratorPasswordController extends Controller
{
    public function resetOwnPassword(Request $request)
    {
        if(!$request->filled('old_strator_password') || !$request->filled('new_strator_password')){
            return $this->fail('旧密码和新密码都不能为空');
        }
        $strator=$request->user();
        if(!Hash::check($request->old_strator_password,$strator->strator_password)){
            return $this->fail('旧密码不正确');
        }
        $strator->strator_password=Hash::make($request->new_strator_password);
        $strator->save();
        $this->saveOperationLog('修改自己账号密码');
        return $this->successMsg();
    }


}
